package com.jacquesh;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class FlinkDemo0016 {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment environment =
                StreamExecutionEnvironment.getExecutionEnvironment();
        /**设置默认并行度为4*/
        environment.setParallelism(4);
        /**获取随机数流 ： 1~4*/
        DataStreamSource<Long> stream = environment.generateSequence(1,4)
                /**并行度设置为2*/
                .setParallelism(2);
             stream
                     .forward()
                     .print()
                     /**下游的并行度必须和上游一样*/
                     .setParallelism(2);
        environment.execute("broadcast");
    }
}
